package com.lwx.test;

public class FloorDemo {
    public static void main(String[] args) {
        int step = FloorDemo.step(10);
        System.out.println(step);
    }
    /**
     * 楼梯的个数为floorNum时，返回上楼梯的可能数
     * @param floorNum
     * @return
     */
    public static int step(int floorNum){
        if(floorNum < 0){
            throw new IllegalArgumentException("floorNum is error");
        }else if(floorNum == 0){
            return 0;
        }else if(floorNum == 1){
            return 1;
        }else if(floorNum == 2){
            return 2;
        }
        if(floorNum > 2){
            return step(floorNum-1)+step(floorNum-2);
        }
        return 0;
    }
}
